#### Figure A5 and A6 Script ####


rm(list=ls());gc();gc();gc();gc();gc();gc();gc();gc()


library(Hmisc)
library(tidyverse)
library(dplyr)
library(hrbrthemes)
library(stargazer)

here::i_am("Scripts/FigA5A6Script.R")

library(here)

## Figure A5 ####
#First let's get the Michigan events:
mich<-readRDS(here("Data", "events_mi.rds"))


pdf(here("Results", "FigA5.pdf"),height=4,width=6)
hist(log10(1+mich$rTotal_cost),main="",xlab="Dollars (log, base 10)",xaxt="n",breaks=8)
axis(side=1,labels=c("0","10","100","1,000","10,000","100,000"),at=c(0,1,2,3,4,5))
dev.off()

## Figure A6 ####

#OH events
oh<-readRDS(here("Data", "events_oh.rds"))

#Background summary stats
summary(c(oh$Freq,mich$attendance[mich$attendance>0]))

pdf(here("Results", "FigA6.pdf"),height=6,width=12)
par(mfrow=c(1,2)) #Distribution of Fundraising-Event Attendance / Ticket Purchases in Michigan and Ohio
#hist(log10(1+df4$rTotal_cost),main="Distribution of Fundraising-Event Total Costs to Candidates",xlab="Dollars (log, base 10)")
hist(log10(c(mich$attendance)),main="(1) Michigan",xlab="Attendees (log, base 10)",xaxt="n",breaks=20)
axis(side=1,labels=c("1","10","100","1,000"),at=c(0,1,2,3))
hist(log10(c(oh$Freq)),main="(2) Ohio",xlab="Donations per Event (log, base 10)",xaxt="n",breaks=20)
axis(side=1,labels=c("1","10","100","1,000"),at=c(0,1,2,3))
dev.off()

#Descriptive Stats included in Paper

#OH
summary(c(oh$Freq))
#median 16 (6, 35)


#MI
summary(mich$attendance[mich$attendance>0])
#median 40 (25, 60)




